//
//  BaseModel.m
//  OurTourism
//
//  Created by dllo on 15/11/23.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel
- (instancetype)initWithDictionary:(NSDictionary *)dic
{
    self = [super init];
    if(self){
        //给对象自己KVC赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}


+ (NSMutableArray *)transformWithArray:(NSArray *)array
{
    // 定义用于返回的可变数组
    NSMutableArray *tempArr = [NSMutableArray array];
    // 便利数组
    for (NSDictionary *dic in array) {
        //  自动释放池
        @autoreleasepool {
            //创建对象
            id model = [self modelWithDictionary:dic];
            //添加数组
            [tempArr addObject:model];
        }
    }
    //返回数组
    return tempArr;
}
//便利构造器
+ (instancetype)modelWithDictionary:(NSDictionary *)dic
{
    id model =  [[[self class] alloc] initWithDictionary:dic];
    return model;
}

// kvc  赋值容错
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}
@end
